<?php

namespace Yj\Generator\Core\Processor;

use Hyperf\Database\Model\SoftDeletes;
use Hyperf\Di\Annotation\Inject;
use Yj\Generator\Core\Config;
use Yj\Generator\Core\Helper\Helper;
use Yj\Generator\Core\Model\EloquentModel;
use Yj\Generator\Core\Model\UseClassModel;
use Yj\Generator\Core\Model\UseTraitModel;

/**
 * @Notes: []
 * @User: zwc
 * @Date: 2022/3/1 14:37
 */
class TraitProcessor
{
    protected $traits = [
        SoftDeletes::class
    ];
    /**
     * @Inject()
     * @var Helper
     */
    protected $helper;

    public function process(EloquentModel $eloquentModel, Config $config)
    {
        collect($this->traits)->each(function ($trait)use ($eloquentModel){
            $eloquentModel->addUses(new UseClassModel($trait));
            $eloquentModel->addTrait(new UseTraitModel($this->helper->getShortClassName($trait)));
        });

    }
}